<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加省代理</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<script src="__PUBLIC__/static/js/area/area.js" ></script>
	</head>

	<body>
		<form class="layui-form update_form" >
			<input type="hidden" name="id" value="{$ad.id}" />
			<div class="layui-form-item">
				<label class="layui-form-label">省份</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<input type="text"   autocomplete="off" class="layui-input" value="{$ad.province}" readonly="readonly"> 
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手机号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="mobile" readonly="readonly" required lay-verify="required" value="{$ad.mobile}" autocomplete="off" class="layui-input"> (作为登录账号)
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">代理名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_name" required lay-verify="required" value="{$ad.user_name}" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">登录密码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="password" placeholder="登录密码" required lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="1" title="正常">
					<input type="radio" name="status" value="2" title="冻结" checked>
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit type="button" lay-filter="submit_from">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>
			layui.use('form', function() {
				var form = layui.form;
				
				//监听表单提交
				form.on('submit(submit_from)', function(data){
					edit_agency();
		  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
			});
			//提交表单
			function edit_agency() {
				$.ajax({
					type: "post",
					url: "{:url('oem/accounts/edit_agency')}",
					data: $('.layui-form').serialize(), //表单数据
					success: function(data) {
						if(data.code == 200) {
							layer.msg('修改成功', {
								icon: 1,
								time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								parent.layer.close(index);
							});
						} else {
							layer.msg('修改失败！'); //保存成功提示
						}
					},
					error: function(data) {
						var a = data;
					}
				});

			}
		</script>
	</body>

</html>